import { ref, Ref } from 'vue';
import { saveYaYData } from '@/api/readPathology/readPathology';
import type * as Type from '@/api/readPathology/readPathology.d';

export default function useToolBarRadio(arListData: Ref<Type.ArItem[] | null>) {

    // 阴阳性是否展示
    const radioVisible = ref<boolean>(false);

    // 阴阳性选择值
    // const radioChecked = ref(true);
    const radioChecked = ref<boolean | undefined>(undefined);

    // 阴阳性点击
    const handleRadioClick = async (type: number) => {
        if (arListData.value?.length !== 0) {
            radioChecked.value = type === 1;
            const params = {
                arId: arListData.value! && arListData.value[0].id,
                yay: type
            }
            const res = await saveYaYData(params);
        }
    };

    return {
        radioChecked,
        radioVisible,
        handleRadioClick
    };
};